function species = GetSubjectSpecies(SubjectID)
% GetSubjectSpecies calls DaRIS to get the subject's species/animal name
%
% Usage: 
%   >> SubjectID ='1008.2.18.3'
%   >> s = GetSubjectSpecies(SubjectID)
%
%  - Michael Eager (michael.eager@monash.edu)

%     Copyright © 2012-2013 Michael Eager <michael.eager@monash.edu> 
%
%     This file is part of Xglom.
% 
%     This is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     (at your option) any later version.
% 
%     This is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
% 
%     You should have received a copy of the GNU General Public License
%     along with this program.  If not, see <http://www.gnu.org/licenses/>.


[status output] = system(['source ./dcheck; $MFCOMMAND asset.get :cid ' SubjectID ' | grep species-strain '])

if status
    errordlg('GetSubjectSpecies was unable to get the subject''s species. Please check that you are logged into Daris, and try again.  Otherwise email your DaRIS administrator.', 'Xglom Error Dialog');
else
     line = regexp(output,'"','split');
     species = char(line(2));
end